//
//  HLHomeListVideoCell.m
//  YueYue
//
//  Created by hulu001 on 2023/5/25.
//

#import "HLHomeListVideoCell.h"

@interface HLHomeListVideoCell ()

@property (nonatomic, strong) UIImageView *iconView;

@property (nonatomic, strong) QMUIButton *videoButton;
@property (nonatomic, strong) UILabel *priceLabel;
@property (nonatomic, strong) UILabel *unitLabel;
@property (nonatomic, strong) UIImageView *videoView;

@end

@implementation HLHomeListVideoCell


-(instancetype)initWithFrame:(CGRect)frame{
    
    if ([super initWithFrame:frame]) {
        self.backgroundColor= UIColorWhite;
        [self setupView];
    }
    return self;
    
}

- (void)setupView {
    self.iconView = [[UIImageView alloc] init];
    _iconView.userInteractionEnabled = NO;
    _iconView.layer.masksToBounds = YES;
    _iconView.layer.cornerRadius = 8;
    _iconView.contentMode = UIViewContentModeScaleAspectFill;
    [self.contentView addSubview:_iconView];
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    
    self.videoButton = [[QMUIButton alloc] init];
    [_videoButton setImage:[UIImage qmui_imageWithColor:[UIColor qmui_colorWithHexString:@"#00AAA9"] size:CGSizeMake(4, 4) cornerRadius:2] forState:UIControlStateNormal];
    [_videoButton setTitle:@"可视频" forState:UIControlStateNormal];
    [_videoButton setTitleColor:UIColorWhite forState:UIControlStateNormal];
    [_videoButton.titleLabel setFont:UIFontMake(8)];
    _videoButton.imagePosition = QMUIButtonImagePositionLeft;
    _videoButton.spacingBetweenImageAndTitle = 2;
    [_videoButton setContentEdgeInsets:UIEdgeInsetsMake(2, 2, 2, 4)];
    _videoButton.cornerRadius = 4;
    [_videoButton setBackgroundColor:[UIColorBlack colorWithAlphaComponent:0.7]];
    [self.contentView addSubview:_videoButton];
    [_videoButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(4);
    }];
    
    self.priceLabel = [[UILabel alloc] qmui_initWithFont:UIFontMediumMake(12) textColor:UIColorWhite];
    _priceLabel.text = @"19";
    [self.contentView addSubview:_priceLabel];
    [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_videoButton);
        make.bottom.mas_equalTo(-8);
    }];
    
    self.unitLabel = [[UILabel alloc] qmui_initWithFont:UIFontMake(8) textColor:[UIColorWhite colorWithAlphaComponent:0.7]];
    _unitLabel.text = @"豆/分钟";
    [self.contentView addSubview:_unitLabel];
    [_unitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_priceLabel.mas_right).offset(2);
        make.centerY.equalTo(_priceLabel);
    }];
    
    self.videoView = [[UIImageView alloc] initWithImage:UIImageMake(@"home_video_icon")];
    [self.contentView addSubview:_videoView];
    [_videoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_unitLabel);
        make.right.mas_equalTo(-4);
    }];
}

- (void)setModel:(HLHomeListModel *)model
{
    _model = model;
    [_iconView sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:[HLUIHelper avatarBigPlaceholder]];
    _priceLabel.text = [NSString stringWithFormat:@"%ld",[model.videoUnit integerValue]];
    
}

@end
